﻿#include "FITKGraphObjectMeshModelBase.h"

// VTK
#include <vtkProperty.h>
#include <vtkAlgorithm.h>

 // Case
#include "FITK_Component/FITKAbaqusData/FITKDataCaseManager.h"
#include "FITK_Component/FITKAbaqusData/FITKDataCase.h"
#include "FITK_Component/FITKAbaqusData/FITKAbaqusData.h"

// Data
#include "FITK_Component/FITKAbaqusData/FITKAbaqusPart.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaMeshPartVTK.h"
#include "FITK_Interface/FITKInterfaceMesh/FITKMeshFeatureVTK.h"
#include "FITK_Interface/FITKInterfaceModel/FITKComponentManager.h"
#include "FITK_Interface/FITKInterfaceModel/FITKMeshSurfaceElement.h"

// Color assign
#include "FITK_Interface/FITKInterfacePhysics/FITKAbstractSection.h"
#include "FITK_Interface/FITKInterfacePhysics/FITKAbstractMaterial.h"
#include "FITK_Interface/FITKInterfacePhysics/FITKSectionAssign.h"
#include "FITK_Interface/FITKInterfacePhysics/FITKMaterialAssign.h"

// Graph and filter
#include "FITK_Interface/FITKVTKAlgorithm/FITKHighOrderCellFilter.h"
#include "FITK_Interface/FITKVTKAlgorithm/FITKShellFeatureEdges.h"
#include "FITK_Interface/FITKVTKAlgorithm/FITKGraphActor.h"
#include "FITKColorMap.h"
#include "FITKGraphCommons.h"
#include "FITKGraphObjectModelHighlighting.h"

// Filter
#include "FITK_Interface/FITKVTKAlgorithm/FITKSurfaceFilter.h"

// Interface
#include "FITK_Interface/FITKInterfaceModel/FITKAbstractModel.h"
#include "FITK_Interface/FITKInterfaceModel/FITKElementList.h"

namespace Exchange
{
    FITKGraphObjectMeshModelBase::FITKGraphObjectMeshModelBase(AbaqusData::FITKDataCase* caseData, Interface::FITKAbstractModel* model)
        : FITKGraphObjectModelBase(caseData, model)
    {
        // Initialize polygon offset.
        m_polygonOffset = FITKGraphCommons::s_meshPolyOffset;
    }

    void FITKGraphObjectMeshModelBase::setPointVisible(bool visible)
    {
        // Show or hide the points.
        if (m_fActorPoint)
        {
            m_fActorPoint->SetVisibility(visible);
        }
    }

    void FITKGraphObjectMeshModelBase::setPointProperties(int pixelSize, QColor color)
    {
        if (!m_fActorPoint)
        {
            return;
        }

        // Check the size value.
        if (pixelSize > 0)
        {
            m_fActorPoint->GetProperty()->SetPointSize(pixelSize);
        }

        // Check the color.
        if (color.isValid())
        {
            double color3[3]{ 0., 0., 0. };
            FITKGraphCommons::QColorToDouble3(color, color3);
            m_fActorPoint->GetProperty()->SetColor(color3);
        }
    }

    void FITKGraphObjectMeshModelBase::setVisible(bool visibility)
    {
        Q_UNUSED(visibility);

        // The instance is special, for some of the actors need to be hidden in some render mode,
        // so use the 'update()' instead.
        update();
    }

    void FITKGraphObjectMeshModelBase::update(bool forceUpdate)
    {
        Q_UNUSED(forceUpdate);

        // Update the visibility.
        QColor color = m_surfaceColorForHidden;
        setRenderModelPrivate(m_viewMode, color);

        // If the model has been hidden, then hide the highlight object, too.
        if (!getDataVisibility())
        {
            disHighlight();
        }
    }

    void FITKGraphObjectMeshModelBase::setRenderModel(ModelViewMode mode, QColor color)
    {
        // If the render mode is not supported or the value is invalid, then return false.
        bool isValid = setRenderModelPrivate(mode, color);
        if (isValid)
        {
            m_viewMode = mode;
            m_surfaceColorForHidden = color;
        }
    }

    void FITKGraphObjectMeshModelBase::setEnableTranslucency(bool isOn)
    {
        m_enabledTranslucency = isOn;

        // Update the view mode.
        if (m_viewMode == ModelHidden)
        {
            QColor color;
            setRenderModelPrivate(ModelWireframe, color);
        }
        else if (m_viewMode == ModelShaded)
        {
            setTranslucency(m_translucency);
        }
    }

    void FITKGraphObjectMeshModelBase::setTranslucency(double value)
    {
        m_translucency = value;

        // Check if the face actor is valid.
        if (!m_fActorFace || !m_enabledTranslucency || m_viewMode != ModelShaded)
        {
            return;
        }

        // Check the input value. 
        value = qMax(qMin(value, 1.), 0.);

        // Set the transparency.
        m_fActorFace->GetProperty()->SetOpacity(qMax(qMin(1. - value, 1.), 0.));

        // Show edge if the translucency is 0.
        if (m_fActorAddin && m_viewMode == ModelShaded)
        {
            m_fActorAddin->SetVisibility(qFuzzyCompare(m_translucency, 1.));
        }
    }

    void FITKGraphObjectMeshModelBase::setFeatureVisible(bool visibility)
    {
        if (m_fActorFeature)
        {
            m_fActorFeature->SetVisibility(visibility);
        }
    }

    void FITKGraphObjectMeshModelBase::colorByDoubleFaces(bool forceUpdate)
    {
        // If the color mode is the same as current mode, return.
        if (m_colorMode == ColorMode::ColorDoubleFaces && !forceUpdate)
        {
            return;
        }

        // Check if the surface actor is generated.
        if (!m_fActorFace || !m_isShellModel)
        {
            return;
        }

        // Disable scalar first.
        m_fActorFace->setScalarVisibility(false);

        // Enable the back face render.
        m_fActorFace->setFrontFaceColor(FITKGraphCommons::s_shellFrontColor);
        m_fActorFace->setBackFaceColor(FITKGraphCommons::s_shellBackColor);

        // Set the color mode value.
        m_colorMode = ColorMode::ColorDoubleFaces;
    }

    void FITKGraphObjectMeshModelBase::initActors()
    {
        // Generate surface actor and add to data list.
        m_fActorFace = FITKGraphActor::New();
        m_fActorFace->setActorType(ActorType::SurfaceActor);
        m_fActorFace->setDataType(DataType::MeshData);
        m_fActorFace->setGraphObject(this);
        m_fActorFace->SetPickable(true);
        m_fActorFace->setRelativeCoincidentTopologyPolygonOffsetParameters(m_polygonOffset);
        addActor(m_fActorFace);

        // Generate point actor and add to data list.
        m_fActorPoint = FITKGraphActor::New();
        m_fActorPoint->setActorType(ActorType::VertexActor);
        m_fActorPoint->setDataType(DataType::MeshData);
        m_fActorPoint->setGraphObject(this);
        m_fActorPoint->SetPickable(false);
        m_fActorPoint->SetVisibility(false);
        m_fActorPoint->GetProperty()->SetRepresentation(0);
        m_fActorPoint->setRelativeCoincidentTopologyPolygonOffsetParameters(m_polygonOffset);
        addActor(m_fActorPoint);

        // Generate additional face actor for 'Hidden' and add to data list.
        m_fActorAddin = FITKGraphActor::New();
        m_fActorAddin->setActorType(ActorType::SurfaceActor);
        m_fActorAddin->setDataType(DataType::MeshData);
        m_fActorAddin->setGraphObject(this);
        m_fActorAddin->SetPickable(false);
        m_fActorAddin->SetVisibility(false);
        m_fActorAddin->setRelativeCoincidentTopologyPolygonOffsetParameters(m_polygonOffset);
        addActor(m_fActorAddin);

        // Initialize properties.
        initActorProperties(m_fActorFace);
    }

    void FITKGraphObjectMeshModelBase::initFeatureActor()
    {
        // Create the feature edge actor.
        m_fActorFeature = FITKGraphActor::New();
        m_fActorFeature->setActorType(ActorType::EdgeActor);
        m_fActorFeature->setDataType(DataType::MeshData);
        m_fActorFeature->setGraphObject(this);
        m_fActorFeature->SetPickable(true);
        m_fActorFeature->SetVisibility(false);
        m_fActorFeature->setScalarVisibility(false);
        m_fActorFeature->GetProperty()->SetEdgeColor(0., 0., 0.);
        m_fActorFeature->GetProperty()->SetColor(0., 0., 0.);
        m_fActorFeature->GetProperty()->SetRepresentation(1);
        // m_fActorFeature->GetProperty()->SetDiffuseColor(1, 1, 1);
        m_fActorFeature->setRelativeCoincidentTopologyPolygonOffsetParameters(m_polygonOffset);
        addActor(m_fActorFeature);
    }

    void FITKGraphObjectMeshModelBase::highlight(QColor color)
    {
        // If the object is invisible, then return.
        // New version.
        //@{
        if (!m_graphObjHighlight || !getDataVisibility())
        {
            return;
        }

        m_graphObjHighlight->highlight(color);
        //@}

        this->Superclass::highlight(color);
    }

    void FITKGraphObjectMeshModelBase::disHighlight()
    {
        // Old version.
        //@{
        //if (!m_fActorFace || !m_isHighlighting)
        //{
        //    return;
        //}

        //m_fActorFace->GetProperty()->SetEdgeColor(0., 0., 0.);
        //m_fActorFace->GetProperty()->SetLineWidth(1.);

        //// Dis-highlight the graph actors.
        //QColor color = m_surfaceColorForHidden;
        //setRenderModelPrivate(m_viewMode, color);
        //@}

        // New version.
        //@{
        if (m_graphObjHighlight && m_isHighlighting)
        {
            m_graphObjHighlight->disHighlight();
        }

        if (m_graphObjPreHighlight && m_isPreHighlighting)
        {
            m_graphObjPreHighlight->disHighlight();
        }
        //@}

        this->Superclass::disHighlight();
    }

    void FITKGraphObjectMeshModelBase::preHighlight()
    {
        // If the object is invisible, then return.
        if (!m_graphObjPreHighlight || !getDataVisibility())
        {
            return;
        }

        m_graphObjPreHighlight->highlight();

        this->Superclass::preHighlight();
    }

    void FITKGraphObjectMeshModelBase::simplified(bool enabled)
    {
        // Check if the model need to be simplified.
        if (!m_simplifiedModel)
        {
            return;
        }

        if (!m_fActorFace || !m_graphSimplified)
        {
            return;
        }

        // Change the model view mode to wireframe while changing the camera.
        QColor color = m_surfaceColorForHidden;
        setRenderModelPrivate(enabled ? ModelWireframe : m_viewMode, color);

        // If the model is not full, then it will be forced simplified to wireframe.
        if (m_simplifiedWithFeature && m_isModelFull)
        {
            if (m_modelEdgeFilter && m_modelFilter)
            {
                m_fActorFace->setInputConnection(enabled ? m_modelEdgeFilter->GetOutputPort() : m_modelFilter->GetOutputPort());
            }
        }
    }

    void FITKGraphObjectMeshModelBase::setPickable(bool isPickable, int dim)
    {
        Q_UNUSED(dim);

        if (m_fActorFace)
        {
            m_fActorFace->SetPickable(isPickable);
        }

        if (m_fActorFeature)
        {
            m_fActorFeature->SetPickable(isPickable);
        }
    }

    bool FITKGraphObjectMeshModelBase::getDataVisibility()
    {
        // Check the data object.
        Interface::FITKAbstractModel* model = dynamic_cast<Interface::FITKAbstractModel*>(_dataObj);
        if (!model)
        {
            return false;
        }

        // Get the visibility from the model data.
        bool enabled = model->isEnable();
        return enabled;
    }

    void FITKGraphObjectMeshModelBase::colorByDefaultForPart(Core::FITKAbstractDataObject* partModel)
    {
        Q_UNUSED(partModel);

        // Check the mesh data object and the actor pointer.
        if (!m_fActorFace || !m_colorMap || !m_featureMesh)
        {
            return;
        }

        // Enable show color with scalar.
        //@{
        m_fActorFace->setScalarVisibility(true);
        m_fActorFace->setScalarModeToUseCellFieldData();
        //@}

        // Set all face to the default color.
        int nCells = m_meshData->getNumberOfCells();
        QList<int> indice;
        for (int i = 0; i < nCells; i++)
        {
            indice.push_back(i);
        }
   
        m_colorMap->setCellsColor(c_defaultArrName, indice, FITKGraphCommons::s_defaultMeshColor);

        // Update the data if neccessary.
        bool needUpdate = m_colorMap->needUpdate();
        if (needUpdate)
        {
            // Update mesh color.
            m_featureMesh->update();

            // Update the color map.
            m_colorMap->update();
        }

        // Switch to the array.
        m_fActorFace->selectScalarArray(c_defaultArrName);
        m_fActorFace->update();
    }

    void FITKGraphObjectMeshModelBase::colorByMaterialForPart(Core::FITKAbstractDataObject* partModel)
    {
        // Down cast data object.
        AbaqusData::FITKAbaqusPart* part = AbaqusData::FITKAbaqusPart::SafeDownCastFITKAbaqusPart(partModel);
        if (!m_caseData || !part || !m_fActorFace || !m_colorMap || !m_featureMesh)
        {
            return;
        }

        // Get the section, assign and set manager, and also the model's color map.
        Interface::FITKAbstractSectionManager* secMgr = m_caseData->getSectionManager();
        Interface::FITKSectionAssignManager* assMgr = part->getSectionAssignManager();
        Interface::FITKComponentManager* setMgr = part->getComponentManager();

        if (!secMgr || !assMgr || !setMgr)
        {
            return;
        }

        // Enable show color with scalar.
        //@{
        m_fActorFace->setScalarVisibility(true);
        m_fActorFace->setScalarModeToUseCellFieldData();
        //@}

        // Filled color with none color first.
        //@{
        QList<int> indiceInit;
        int nCell = m_meshData->getNumberOfCells();
        for (int i = 0; i < nCell; i++)
        {
            indiceInit.push_back(i);
        }

        m_colorMap->setCellsColor(c_materialArrName, indiceInit, FITKGraphCommons::s_noneColor);
        //@}

        // Get all assigned sections.
        int nAssign = assMgr->getDataCount();
        for (int i = 0; i < nAssign; i++)
        {
            // Get assign.
            Interface::FITKSectionAssign* assign = assMgr->getDataByIndex(i);
            if (!assign)
            {
                continue;
            }

            // Get set.
            int setId = assign->getModelID();
            Interface::FITKAbstractModelComponent* set = setMgr->getDataByID(setId);
            if (!set)
            {
                continue;
            }

            // Convert to model set.
            Interface::FITKModelSet* modelSet = dynamic_cast<Interface::FITKModelSet*>(set);
            if (!modelSet)
            {
                continue;
            }

            // Get section.
            int secDataId = assign->getSectionID();
            Interface::FITKAbstractSection* sec = secMgr->getDataByID(secDataId);

            int matId = -1;
            bool hasValidSecAndMat = false;

            if (sec)
            {
                // The section ID.
                int secId = sec->getSectionID();
                if (secId > 0)
                {
                    secId--;
                }

                // Get material id.
                Interface::FITKAbstractMaterial* mat = sec->getMaterial();
                if (mat)
                {
                    hasValidSecAndMat = true;
                    matId = mat->getMaterialID();
                }

                if (matId > 0)
                {
                    matId--;
                }
            }

            // Get element set(s).
            QList<Interface::FITKModelSet*> sets;
            modelSet->getAbsoluteSet(sets, Interface::FITKModelEnum::FITKModelSetType::FMSElem);

            for (Interface::FITKModelSet* s : sets)
            {
                // Get element indice and the material color need to be set.
                QList<int> indice;
                getSetIds(s, indice);

                if (hasValidSecAndMat)
                {
                    QColor color = FITKGraphCommons::GetColorByIndex(matId);
                    m_colorMap->setCellsColor(c_materialArrName, indice, color);
                }
                else
                {
                    m_colorMap->setCellsColor(c_materialArrName, indice, FITKGraphCommons::s_notFoundColor);
                }
            }
        }

        // Update the data if neccessary.
        bool needUpdate = m_colorMap->needUpdate();
        if (needUpdate)
        {
            // Update mesh color.
            m_featureMesh->update();

            // Update the color map.
            m_colorMap->update();
        }

        // Switch to the array.
        m_fActorFace->selectScalarArray(c_materialArrName);
        m_fActorFace->update();
    }

    void FITKGraphObjectMeshModelBase::colorBySectionForPart(Core::FITKAbstractDataObject* partModel)
    {
        // Get the part data object.
        AbaqusData::FITKAbaqusPart* part = AbaqusData::FITKAbaqusPart::SafeDownCastFITKAbaqusPart(partModel);
        if (!m_caseData || !part || !m_fActorFace || !m_colorMap || !m_featureMesh)
        {
            return;
        }

        // Get the section, assign and set manager, and also the model's color map.
        Interface::FITKAbstractSectionManager* secMgr = m_caseData->getSectionManager();
        Interface::FITKSectionAssignManager* assMgr = part->getSectionAssignManager();
        Interface::FITKComponentManager* setMgr = part->getComponentManager();

        if (!secMgr || !assMgr || !setMgr)
        {
            return;
        }

        // Enable show color with scalar.
        //@{
        m_fActorFace->setScalarVisibility(true);
        m_fActorFace->setScalarModeToUseCellFieldData();
        //@}

        // Filled color with none color first.
        //@{
        QList<int> indiceInit;
        int nCell = m_meshData->getNumberOfCells();
        for (int i = 0; i < nCell; i++)
        {
            indiceInit.push_back(i);
        }

        m_colorMap->setCellsColor(c_sectionArrName, indiceInit, FITKGraphCommons::s_noneColor);
        //@}

        // Get all assigned sections.
        int nAssign = assMgr->getDataCount();
        for (int i = 0; i < nAssign; i++)
        {
            // Get assign.
            Interface::FITKSectionAssign* assign = assMgr->getDataByIndex(i);
            if (!assign)
            {
                continue;
            }

            // Get set.
            int setId = assign->getModelID();
            Interface::FITKAbstractModelComponent* set = setMgr->getDataByID(setId);

            // Convert to model set.
            Interface::FITKModelSet* modelSet = dynamic_cast<Interface::FITKModelSet*>(set);
            if (!modelSet)
            {
                continue;
            }

            // Get section.
            int secDataId = assign->getSectionID();
            Interface::FITKAbstractSection* sec = secMgr->getDataByID(secDataId);

            // The section ID.
            int secId = sec->getSectionID();
            if (secId > 0)
            {
                secId--;
            }

            // Get element set(s).
            QList<Interface::FITKModelSet*> sets;
            modelSet->getAbsoluteSet(sets, Interface::FITKModelEnum::FITKModelSetType::FMSElem);

            for (Interface::FITKModelSet* s : sets)
            {
                // Get element indice and the section color need to be set.
                QList<int> indice;
                getSetIds(s, indice);

                if (sec)
                {
                    QColor color = FITKGraphCommons::GetColorByIndex(secId);
                    m_colorMap->setCellsColor(c_sectionArrName, indice, color);
                }
                else
                {
                    m_colorMap->setCellsColor(c_sectionArrName, indice, FITKGraphCommons::s_notFoundColor);
                }
            }
        }

        // Update the data if neccessary.
        bool needUpdate = m_colorMap->needUpdate();
        if (needUpdate)
        {
            // Update mesh color.
            m_featureMesh->update();

            // Update the color map.
            m_colorMap->update();
        }

        // Switch to the array.
        m_fActorFace->selectScalarArray(c_sectionArrName);
        m_fActorFace->update();
    }

    void FITKGraphObjectMeshModelBase::colorByDefaultMeshForPart(Core::FITKAbstractDataObject* partModel)
    {
        // Get the part data object.
        AbaqusData::FITKAbaqusPart* part = AbaqusData::FITKAbaqusPart::SafeDownCastFITKAbaqusPart(partModel);
        if (!m_caseData || !part || !m_fActorFace || !m_colorMap)
        {
            return;
        }

        // Enable show color with scalar.
        //@{
        m_fActorFace->setScalarVisibility(true);
        m_fActorFace->setScalarModeToUseCellFieldData();
        //@}

        // Get the mesh color.
        QColor color;

        // Check whether the part has a valid geometry data.
        if (part->getGeoCommandObj())
        {
            color = FITKGraphCommons::s_defaultGeoMeshColor;
        }
        else
        {
            color = FITKGraphCommons::s_defaultMeshColor;
        }

        // Filled color with the color.
        //@{
        QList<int> indiceInit;
        int nCell = m_meshData->getNumberOfCells();
        for (int i = 0; i < nCell; i++)
        {
            indiceInit.push_back(i);
        }

        m_colorMap->setCellsColor(c_sectionArrName, indiceInit, color);
        //@}

        // Update the data if neccessary.
        bool needUpdate = m_colorMap->needUpdate();
        if (needUpdate)
        {
            // Update mesh color.
            m_featureMesh->update();

            // Update the color map.
            m_colorMap->update();
        }

        // Switch to the array.
        m_fActorFace->selectScalarArray(c_sectionArrName);
        m_fActorFace->update();
    }

    void FITKGraphObjectMeshModelBase::getSetIds(Interface::FITKModelSet* set, QList<int> & indice)
    {
        indice.clear();

        if (!set || !m_meshData)
        {
            return;
        }

        // Get real members.
        QList<int> members = set->getAbsoluteMember();

        // Get real indice.
        for (int& id : members)
        {
            int index = m_meshData->getEleIndexByID(id);
            if (index != -1)
            {
                indice.push_back(index);
            } 
        }
    }

    void FITKGraphObjectMeshModelBase::initActorProperties(vtkProp* actor, QVariant details)
    {
        Q_UNUSED(details);

        if (!actor)
        {
            return;
        }

        // Set model actor properties.
        // Default show face and edge.
        FITKGraphActor* fActor = FITKGraphActor::SafeDownCast(actor);
        if (!fActor)
        {
            return;
        }

        fActor->GetProperty()->SetEdgeColor(0., 0., 0.);
        fActor->GetProperty()->SetLineWidth(1.);
    }

    bool FITKGraphObjectMeshModelBase::setRenderModelPrivate(ModelViewMode mode, QColor & color)
    {
        // Check if the face actor is valid.
        if (!m_fActorFace || !m_fActorAddin)
        {
            return false;
        }

        // Get the data visibility.
        bool visibility = getDataVisibility();

        switch (mode)
        {
        case ModelShaded:
        {
            color = QColor();

            setTranslucency(m_translucency);
            m_fActorFace->GetProperty()->SetEdgeVisibility(true);
            m_fActorFace->GetProperty()->SetRepresentation(2);
            m_fActorFace->SetVisibility(visibility);
            setLightPropertiesForSurface(m_fActorFace);

            // The wireframe must be shown forever.
            m_fActorAddin->GetProperty()->SetColor(0., 0., 0.);
            m_fActorAddin->GetProperty()->SetEdgeVisibility(true);
            m_fActorAddin->GetProperty()->SetRepresentation(1);
            m_fActorAddin->SetVisibility(visibility);
            setLightPropertiesForLine(m_fActorAddin);

            // Hide edge if the translucency is 0.
            m_fActorAddin->SetVisibility(qFuzzyCompare(m_translucency, 1.));

            break;
        }
        case ModelHidden:
        {
            if (!color.isValid())
            {
                return false;
            }

            if (m_enabledTranslucency)
            {
                m_fActorFace->GetProperty()->SetOpacity(1.);
                m_fActorFace->GetProperty()->SetEdgeVisibility(true);
                m_fActorFace->GetProperty()->SetRepresentation(1);
                m_fActorFace->SetVisibility(visibility);
                setLightPropertiesForLine(m_fActorFace);

                m_fActorAddin->SetVisibility(false);
            }

            // If the color is valid, set the color to the surface.
            double colorDd3[3]{ 0, 0, 0 };
            FITKGraphCommons::QColorToDouble3(color, colorDd3);
            m_fActorAddin->GetProperty()->SetColor(colorDd3);
                
            // Show the wireframe and the surface at the same time.
            m_fActorFace->GetProperty()->SetEdgeVisibility(true);
            m_fActorFace->GetProperty()->SetRepresentation(1);
            setLightPropertiesForLine(m_fActorFace);

            // The face color need to set to the given color.
            m_fActorAddin->GetProperty()->SetEdgeVisibility(false);
            m_fActorAddin->GetProperty()->SetRepresentation(2);
            m_fActorAddin->SetVisibility(visibility ? true : visibility);
            setLightPropertiesForSurface(m_fActorAddin);

            break;
        }
        case ModelWireframe:
        {
            color = QColor();

            m_fActorFace->GetProperty()->SetOpacity(1.);
            m_fActorFace->GetProperty()->SetEdgeVisibility(true);
            m_fActorFace->GetProperty()->SetRepresentation(1);
            m_fActorFace->SetVisibility(visibility);
            setLightPropertiesForLine(m_fActorFace);

            m_fActorAddin->SetVisibility(false);

            break;
        }
        default:
            return false;
        }

        return true;
    }
}   // namespace Exchange